package com.tierstall.shared;

import java.io.Serializable;

import com.google.gwt.view.client.ProvidesKey;

@SuppressWarnings("serial")
public class UserDTO implements Serializable, Comparable<UserDTO> {
	
	/**
     * The key provider that provides the unique ID of a contact.
     */
    public static final ProvidesKey<UserDTO> KEY_PROVIDER = new ProvidesKey<UserDTO>() {
      public Object getKey(UserDTO item) {
        return item == null ? null : item.getId();
      }
    };

	private String id;
	private String username;
	private String password;
	 private String firstname;
	 private String lastname;
	 private String department ;
	 private String email;
	private UserType permission;

	public UserDTO() {
	}

	public UserDTO(String id) {
		this.id = id;
	}

	public UserDTO(String id, String username, String password, UserType permission,
			String firstname, String lastname, String email, String department) {
		this.id = id;
		this.username = username;
		this.password = password;
		this.permission = permission;
		 this.firstname = firstname;
		 this.lastname = lastname;
		 this.email = email;
		 this.department = department;
	}

	// public UserUUID convertToUserUUID() {
	// UserUUID user = new UserUUID();
	// user.setUsername(getUsername());
	// user.setFirstname(getFirstname());
	// user.setLastname(getLastname());
	// //user.setId(UUID.fromString(useruuid.getId()));
	// user.setPassword(getPassword());
	// user.setPermission(getPermission());
	// user.setDepartment(getDepartment());
	// return user;
	// }

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public UserType getPermission() {
		return permission;
	}

	public void setPermission(UserType permission) {
		this.permission = permission;
	}

	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

//	@Override
//	public int compareTo(UserDTO o) {
//		// TODO Auto-generated method stub
//		return 0;
//	}
	
    @Override
    public boolean equals(Object o) {
      if (o instanceof UserDTO) {
        return id.equals(((UserDTO) o).id);
      }
      return false;
    }

//	@Override
	public int compareTo(UserDTO o) {
		      return (o == null || o.username == null) ? -1
		          : -o.username.compareTo(username);
	}
}
